package com.hspedu.newData.dmsxl.数组.双指针;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-22 
 * @Version: 1.0
 */

public class LC27移除元素 {

    // 双指针
    public int removeElement(int[] nums, int val) {
        int slow = 0;
        int fast = 0;
        while(fast < nums.length){
            if (nums[fast] != val){
                nums[slow++] = nums[fast];
            }
            fast++;
        }
        return slow;
    }

    @Test
    public void test(){
        int[] nums = new int[]{3,2,2,3};
        int i = removeElement(nums, 3);
    }
}
